package com.longmao.formvalidate.controller;

import com.longmao.formvalidate.exception.ValidationException;
import com.longmao.formvalidate.form.RegisterForm;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping(value = "register")
public class RegisterController extends BaseController {

    @PostMapping(value = "")
    public String register(@RequestBody @Validated RegisterForm form, BindingResult bindingResult) throws Exception {

        //validateForm(bindingResult);
        /*if (true) {
            throw new ValidationException(500100, "用户已存在!");
        }

        if (true) {
            throw new Exception();
        }*/
        return "success";
    }

}
